package com.block.channel.factory;

import com.block.channel.enums.ReportChannelEnum;
import com.block.channel.flow.IChannelReportService;
import com.block.channel.flow.channel.*;
import com.block.common.util.ApplicationContextUtil;

import java.util.HashMap;
import java.util.Map;

public class ReportChannelFactory {

    private static final Map<String, Class<? extends IChannelReportService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(ReportChannelEnum.SUOZHII.getValue(), SuoZhiChannelReportService.class);
        serviceMap.put(ReportChannelEnum.TUIA.getValue(), TuiAChannelReportService.class);
        serviceMap.put(ReportChannelEnum.BIANXIANMAO.getValue(), BianXMChannelReportService.class);
        serviceMap.put(ReportChannelEnum.XIANGDIAN.getValue(), XiangDianChannelReportService.class);
        serviceMap.put(ReportChannelEnum.JIZHUN.getValue(), JiZhunChannelReportService.class);

    }

    public static IChannelReportService getService(String channelCode){
        if (serviceMap.containsKey(channelCode)){
            Class<? extends IChannelReportService> aClass = serviceMap.get(channelCode);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }

}
